#include <iostream>
#include <unordered_map>
#include <cmath>
using namespace std;

bool ep(int n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    int i = 5;
    while (i * i <= n) {
        if (n % i == 0 || n % (i + 2) == 0) return false;
        i += 6;
    }
    return true;
}

string bp(string ns) {
    int n = stoi(ns);
    if (n < 100 || n > 999) return "Wrong input";
    int l = n, u = n;
    while (true) {
        if (ep(l)) return to_string(l);
        else if (ep(u)) return to_string(u);
        else { l--; u++; }
    }
}

int main() {
    unordered_map<string, string> w = {
        {"zero", "0"}, {"one", "1"}, {"two", "2"}, {"three", "3"},
        {"four", "4"}, {"five", "5"}, {"six", "6"}, {"seven", "7"},
        {"eight", "8"}, {"nine", "9"}
    };
    string r, es;
    getline(cin, es);
    int d = 0;
    for (char c : es) {
        if (isdigit(c)) d++;
    }
    if (d == 0) {
        string n;
        string word;
        for (char c : es) {
            if (isalpha(c)) {
                word += c;
            } else if (!word.empty()) {
                n += w[word];
                word.clear();
            }
        }
        cout << bp(n);
    } else {
        cout << "Wrong input";
    }
    return 0;
}
